window.onload = function () {
	var setPrice = document.getElementById('price');
	var profit = document.querySelector('.repertory').getElementsByTagName('em')[0];
	var cost = document.querySelector('.cost').getElementsByTagName('em')[0];
	
	setPrice.addEventListener('input', function () {
		forProfit();
	});
	
	function forProfit () {
		var setP = parseInt(setPrice.value);
		var costP = parseInt(cost.innerHTML).toFixed(0);
		var result = ( setP - costP ) > 0 ? ( setP - costP ) : 54;
		profit.innerHTML = '&yen;&nbsp;' + result + '.00';
	}
	
	
	//解决输入可输入e的bug
	document.addEventListener('keyup', function (e){
		var e =  event.keyCode;		
		if( e == 69){
			setPrice.value = '';
		}

	} );
}